package rdd.operate;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.Function;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Spark38_Operate_map {
    public static void main(String[] args) {
        final List<Integer> nums = Arrays.asList(1,2,3,4);
        final SparkConf conf = new SparkConf();
        conf.setMaster("local");
        conf.setAppName("spark");
        //函数式编程可以使用.不断的套用，减少很多的中间对象
        final JavaSparkContext jsc = new JavaSparkContext(conf);

        jsc.parallelize(nums,2)
                 .map( num ->  num * 2 )
                 .collect()
                 .forEach(System.out::println);
        jsc.close();
    }
}
